package com.yiyi.util;

import cn.hutool.core.util.StrUtil;
import net.bytebuddy.description.field.FieldDescription;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 自定义类型转换工具类
 *
 * @author yiyi
 * @date 2021/6/1
 */
public class TypeConverterUtil {

    /**
     * 字符串转字符串型列表
     *
     * @param s
     * @return
     * */
    public static List<String> stringToStringList(String s) {
        s = StrUtil.sub(s, 1, -1);
        s = s.replace(" ", "");
        List<String> stringList = Arrays.asList(s.split(","));
        return stringList;
    }

    /**
     * 字符串转Integer型列表
     *
     * @param s
     * @return
     * */
    public static List<Integer> stringToIntegerList(String s) {
        s = StrUtil.sub(s, 1, -1);
        s = s.replace(" ", "");
        List<String> stringList = Arrays.asList(s.split(","));
        List<Integer> integerList = new ArrayList<>();
        for (String sl : stringList) {
            integerList.add(Integer.valueOf(sl));
        }
        return integerList;
    }
}
